/*
 * AboutWidget.cpp
 *
 *  Created on: Jan 7, 2011
 *      Author: Kevin Mueller
 */

#include "AboutWidget.h"

#include "../logic/Main.h"

#include <QtGui>

AboutWidget::AboutWidget(QWidget *parent) :
	QDialog(parent) {

	setWindowTitle(tr("About OpenNav"));

	QLabel *lIcon = new QLabel();
	QPixmap icon;
	icon.load(IMAGEDIR "/../icons/opennav.png");
	lIcon->setPixmap(icon);

	QString sVersion = "About OpenNav - Version ";
	sVersion.append(__VERSION__);	// TODO: Version von OpenNav und nicht des GCC verwenden
	QLabel *version = new QLabel(sVersion);

	QLabel *compiletime = new QLabel(
			tr("Compiled at: %1 - %2").arg(__DATE__).arg(__TIME__));

	QTextEdit *copyright = new QTextEdit(
			tr("Copyright (c) 2011 by Markus Langpeter &lt;m.langpeter@googlecode.com&gt; and Kevin Mueller &lt;kmueller@live.de&gt;<br>"
					"<br>"
					"This program is published under the GPLv3 available at <a href='http://www.gnu.org/licenses/gpl.html'>http://www.gnu.org/licenses/gpl.html</a>"
					"<br>"
					"<br>"
					"The project website and the Mercurial repository is available at: <a href='https://code.google.com/p/opennav-mobile/'>https://code.google.com/p/opennav-mobile/</a>")
		);
	copyright->setReadOnly(true);
	copyright->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	copyright->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	QBoxLayout *icons = new QVBoxLayout();
	icons->addWidget(lIcon);
	icons->addStretch();

	QBoxLayout *content = new QVBoxLayout();
	content->addWidget(version);
	content->addWidget(compiletime);
	content->addWidget(copyright);

	QPushButton *aboutqt = new QPushButton(tr("About QT"));
	QPushButton *close = new QPushButton(tr("Done"));
	connect(aboutqt, SIGNAL(clicked()), this, SLOT(aboutQT()));
	connect(close, SIGNAL(clicked()), this, SLOT(close()));

	QVBoxLayout *buttons = new QVBoxLayout();
	buttons->addStretch();
	buttons->addWidget(aboutqt);
	buttons->addWidget(close);

	QHBoxLayout *mainLayout = new QHBoxLayout();
	mainLayout->addLayout(icons);
	mainLayout->addLayout(content);
	mainLayout->addLayout(buttons);

	this->setLayout(mainLayout);
}

void AboutWidget::aboutQT() {
	qDebug() << "About QT";
	QMessageBox::aboutQt(this, tr("About QT"));
}

